NewDragItem Function

Defines the drag rectangle (based on the coordinates passed) that will appear when the user drags from the control or window. Returns a new DragItem object.

Syntax

result = NewDragItem( Left, Top, Width, Height )


Parameters

Left

Integer

Left coordinate of the drag rectangle.

Top

Integer

Top coordinate of the drag rectangle.

Width

Integer

Width of the drag rectangle

Height

Integer

Height of the drag rectangle.



Notes

You use NewDragItem in the an event handler of the control from which the user will drag. The MouseDown event handler is an obvious place. Your code uses NewDragItem to create the DragItem and size the drag region. Depending on the type of data being dragged (you can allow for multiple dragitems), you would use the FolderItem, Picture, RawData, or Text properties of the DragItem to store the item(s) being dragged.

If you are dragging from a RectControl, you can also use the NewDragItem method of the RectControl class to create a DragItem.


Example

The following code in the MouseDown event handler of an ImageWell creates a DragItem and enables dragging:

Dim d as DragItem
d=NewDragItem( Me.left, Me.top, Me.width, Me.height)
d.Picture= Me.image
d.Drag //Allow the drag

The following code in the Open event of another ImageWell enables it to receive a dragged picture:

Me.AcceptPictureDrop

The following DropObject event handler assigns the image contained in the DragItem to the control's BackDrop property. This causes it to be displayed.

Sub DropObject(obj as DragItem)
  Me.image=obj.Picture

See Also

DragItem class.